package sorting_strings;

import java.util.List;

public class Sort {

	// will take in a collection of strings and sort them in lexicographical
	// order
	List<String> slist;
	static int total_swaps;

	public Sort(List<String> slist) {

		this.slist = slist;
	}

	public List<String> sortString(List<String> slist) {

		int count = 1;

		while (count != 0) {

			count = 0;
			for (int i = 0; i < slist.size(); i++) {
				try {
					// Thread.sleep(500);

					if (slist.get(i).compareTo(slist.get(i + 1)) > 0) {

						String temp = slist.get(i);
						slist.set(i, slist.get(i + 1));
						slist.set(i + 1, temp);
						count++;
						total_swaps++;

					}
				} catch (Exception e) {

				}

			}

		}
		return slist;

	}

}
